package com.zblog.yuhang.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.zblog.yuhang.domain.Blog;
import com.zblog.yuhang.service.BlogService;

@Controller
public class BlogController {

	@Autowired
	BlogService blogService;
	
	@GetMapping("/blog")
	public ModelAndView intoBlog(@RequestParam(value="blogid") Long id,Model model){
		
		Blog blog = blogService.getBlogById(id);
		model.addAttribute("blog", blog);
		model.addAttribute("title", "Article");
		return new ModelAndView("post", "model", model);
		
		
	}
	
}
